package com.stylefeng.guns.wx.controller;

import com.stylefeng.guns.core.shiro.ShiroKit;
import me.chanjar.weixin.common.bean.WxJsapiSignature;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.cp.api.WxCpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@RequestMapping("/wx")
@Controller
public class WxController {

    @Autowired
    private WxCpService wxCpService;

    @RequestMapping("/getJsAPISignature")
    @ResponseBody
    public WxJsapiSignature get(@RequestParam(value = "url") String url) throws WxErrorException {
        return wxCpService.createJsapiSignature(url);
    }

    @RequestMapping("/currentUser")
    @ResponseBody
    public Object currentUser() {
        return ShiroKit.getUser();
    }

}
